package com.module.controller;


import com.module.framework.domain.NowLend;
import com.module.framework.domain.ResponseResult;
import com.module.framework.dto.BookListDTO;
import com.module.framework.dto.NowLendDTO;
import com.module.framework.mapper.NowLendMapper;
import com.module.framework.service.BookService;
import com.module.framework.service.NowLendService;
import com.module.framework.vo.BookDetailVO;
import com.module.framework.vo.PageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/nowLend")
public class NowLendController {

    @Autowired
    private NowLendService nowLendService;

    @PostMapping("/list")
    public ResponseResult productList(@RequestBody NowLendDTO nowLendDTO) {
        PageVO pageVO = nowLendService.nowLendList(nowLendDTO);
        return ResponseResult.okResult(pageVO);
    }

    @GetMapping("/info")
    public ResponseResult getBookInfo(Integer id) {
        NowLend nowLend = nowLendService.getNowLendInfo(id);
        return ResponseResult.okResult(nowLend);
    }

    @GetMapping("/lendOut")
    public ResponseResult lendBook(Integer id) {
        String num = nowLendService.lendOutBook(id);
        return ResponseResult.okResult(num);
    }

    @GetMapping("/lendBack")
    public ResponseResult lendBack(Integer id) {
        String num = nowLendService.lendBackBook(id);
        return ResponseResult.okResult(num);
    }

    @GetMapping("/lendLoss")
    public ResponseResult lendLoss(Integer id) {
        String num = nowLendService.lendLoss(id);
        return ResponseResult.okResult(num);
    }

    @GetMapping("/lendBack2")
    public ResponseResult lendBack2(Integer id) {
        String num = nowLendService.lendBackBook2(id);
        return ResponseResult.okResult(num);
    }


}
